import ajax from '@/utils/request'
// 发表评论的请求
export const addComment = (artId, content) => {
  return ajax({
    method: 'POST',
    url: '/app/v1_0/comments',
    data: {
      target: artId,
      content: content
    }
  })
}
// 获取评论的请求
export const getComments = (artId, offset) => {
  return ajax({
    method: 'GET',
    url: '/app/v1_0/comments',
    params: {
      type: 'a',
      source: artId,
      offset
    }
  })
}
// 对评论点赞 target 是点赞的评论id
export const addCommentLike = (target) => {
  return ajax({
    method: 'POST',
    url: '/app/v1_0/comment/likings',
    data: {
      target
    }
  })
}
// 取消对评论的点赞 target 是点赞的评论id
export const cancelCommentLike = (target) => {
  return ajax({
    method: 'DELETE',
    url: '/app/v1_0/comment/likings/' + target
  })
}
// 获取回复数据
export const getCommentReplys = (replyId, offset) => {
  return ajax({
    method: 'GET',
    url: '/app/v1_0/comments',
    params: {
      type: 'c',
      source: replyId,
      offset
    }
  })
}
// 对文章编号进行回复
export const addCommentReply = (commentId, content, articleId) => {
  return ajax({
    method: 'POST',
    url: '/app/v1_0/comments',
    data: {
      target: commentId,
      content,
      art_id: articleId
    }
  })
}
